package com.itlong.cloud.app.resource;

import com.alibaba.fastjson.JSONObject;
import com.itlong.cloud.app.service.IAppOldMineService;
import com.itlong.cloud.enumerate.oldapp.Message;
import com.itlong.cloud.user.app.IAppOldMineServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *     旧版APP的我版块接口代理实现
 * </desc>
 *
 * @createDate 2017/11/1
 */
@RestController
public class AppOldMineServiceResource implements IAppOldMineServiceClient {

    @Autowired
    IAppOldMineService iAppOldMineService;

    /**
     * <desc>
     *     旧版APP_邀请家人查询当前用户的业主房间信息
     * </desc>
     * @param userId
     * @param projectId
     * @return
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/1
     */
    @Override
    @RequestMapping(path = "/app/authPerson/ownerUserInfo",method = RequestMethod.POST)
    public JSONObject getUserOwnRoom(@RequestParam("userId") String userId,@RequestParam("projectId") String projectId) throws Exception{
       return iAppOldMineService.getUserOwnRoom(userId,projectId);
    }
    /**
     * <desc>
     *     旧版APP_已授权家人列表
     * </desc>
     * @param projectId
     * @param userId
     * @param pageNo
     * @param pageSize
     * @return
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/2
     */
    @Override
    @RequestMapping(path = "/app/authPerson/list",method = RequestMethod.POST)
    public Message getAuthPersionList(@RequestParam("projectId") String projectId,@RequestParam("userId") String userId,@RequestParam("pageNo") Integer pageNo,@RequestParam("pageSize") Integer pageSize) throws Exception{
        return  iAppOldMineService.getAuthPersionList(projectId,userId,pageNo,pageSize);
    }

    /**
     * <desc>
     *     旧版APP_修改授权人备注
     * </desc>
     * @param userId
     * @param authPhoneNo
     * @param userRemarks
     * @return
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/2
     */
    @Override
    @RequestMapping(path = "/app/authPerson/update",method = RequestMethod.POST)
    public Message updateAuthUserRemark(@RequestParam("userId") String userId,@RequestParam("authPhoneNo") String authPhoneNo,@RequestParam("userRemarks") String userRemarks) throws Exception{
        return  iAppOldMineService.updateAuthUserRemark(userId,authPhoneNo,userRemarks);
    }

    /**
     * <desc>
     *     旧版APP_添加用户反馈信息
     * </desc>
     * @param userId
     * @param projectId
     * @param feedbackInfo
     * @return
     * @throws Exception
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/3
     */
    @Override
    @RequestMapping(path = "/app/feekBack/add",method = RequestMethod.POST)
    public Message addFeekBack(@RequestParam("userId") String userId,@RequestParam("projectId") String projectId,@RequestParam("feedbackInfo") String feedbackInfo) throws Exception{
        return  iAppOldMineService.addFeekBack(userId,projectId,feedbackInfo);
    }

    /**
     * <desc>
     *     旧版APP_删除家人
     * </desc>
     * @param phoneNo
     * @param authPhoneNo
     * @param projectId
     * @return
     * @throws Exception
     * * @author cuiduanwu
     * @createDate 2017/11/2
     */
    @Override
    @RequestMapping(path = "/app/authPerson/delete",method = RequestMethod.POST)
    public Message delUserChild(@RequestParam("phoneNo") String phoneNo,@RequestParam("authPhoneNo") String authPhoneNo,@RequestParam("projectId") String projectId) throws Exception{
        return iAppOldMineService.delUserChild(phoneNo,authPhoneNo,projectId);
    }
    /**
     * <desc>
     *     旧版APP_获取所有正在服务中的小区信息，用户所拥有小区除外
     * </desc>
     * @param phoneNo
     * @return
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/9
     */
    @Override
    @RequestMapping(path = "/app/projectInfo/list",method = RequestMethod.POST)
    public Message getServiceProject(@RequestParam("phoneNo") String phoneNo) throws Exception{
        return iAppOldMineService.getServiceProject(phoneNo);
    }

    /**
     * <desc>
     *      旧版APP_用户添加小区
     * </desc>
     * @param phoneNo
     * @param projectId
     * @param projectName
     * @return
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/9
     */
    @Override
    @RequestMapping(path = "/app/userAddProject",method = RequestMethod.POST)
    public Message addProjectByUser(@RequestParam("phoneNo") String phoneNo,@RequestParam("projectId") String projectId,@RequestParam("projectName") String projectName) throws Exception{

        return iAppOldMineService.addProjectByUser(phoneNo,projectId,projectName);
    }
    /**
     * <desc>
     *     旧版APP_用户删除小区
     * </desc>
     * @param phoneNo
     * @param projectId
     * @return
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/10
     */
    @Override
    @RequestMapping(path = "/app/userDelProject",method = RequestMethod.POST)
    public Message delProjectByUser(@RequestParam("phoneNo") String phoneNo,@RequestParam("projectId") String projectId) throws Exception{
        return iAppOldMineService.delProjectByUser(phoneNo,projectId);
    }


    /**
     * <desc>
     *     旧版APP_用户点击切换小区
     * </desc>
     * @param phoneNo
     * @param projectId
     * @param projectName
     * @return
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/10
     */
    @Override
    @RequestMapping(path = "/app/userChanegProject",method = RequestMethod.POST)
    public Message userChangeProject(@RequestParam("phoneNo") String phoneNo,@RequestParam("projectId") String projectId,@RequestParam("projectName") String projectName) throws Exception{
        return iAppOldMineService.userChangeProject(phoneNo,projectId,projectName);
    }


    /**
     * <desc>
     *     旧版APP_运行日志上传
     * </desc>
     * @param logJson
     * @return
     * @throws Exception
     * @throws Exception
     * @author cuiduanwu
     * @createDate 2017/11/13
     */
    @Override
    @RequestMapping(path = "/app/runLog/upload",method = RequestMethod.POST)
    public Message addRunLog(@RequestParam("logJson") String logJson) throws Exception{
        return  iAppOldMineService.addRunLog(logJson);
    }





















}
